const util = require('../../../utils/util.js');
const http = util.http;

Page({
  data: {
    name: '',
    kind: '',
    size: '',
    nums: '',
    shop_id: ''
  },
  handleApplyOther: function () {
    console.log(this.data);
    const params = {
      shop_id: this.data.shop_id,
      param: {
        name: this.data.name,
        type: this.data.kind,
        spec: this.data.size,
        number: this.data.nums,
      }
    };
    // 接口未到之前，先假提交
    wx.setStorage({
      key: 'applyOtherParts',
      data: params
    });
    wx.showToast({
      title: '申请成功',
      icon: 'none',
    });
    wx.navigateTo({
      url: '../apply/index',
    });
    // http('/parts/applyParts', 'post', params)
    // .then((data) => {
    //   console.log(data);
    //   wx.navigateBack({
    //     delta: 1
    //   })
    // });
  },
  getDeviceInfo: function (e) {
    var type = e.target.dataset.type;
    this.setData({
      [type]: e.detail.value
    })
  },
  onLoad: function (options) {
    var id = options.id;
    console.log(id);
    this.setData({
      shop_id: id
    }); 
  }
})
